//
// Created by ZLY on 2025/5/13.
//

#ifndef TIMER_H
#define TIMER_H
#include "../core/object.h"


class Timer : public Object {
protected:
    float timer_ = 0;
    float timer_interval_ = 3;
    bool time_out_ = false;

public:
    static Timer *addTimerChild(Object *parent, float interval);

    void update(float dt) override;

    void start() {
        if (!is_active_) {
            is_active_ = true;
        }
    }

    void stop() {
        is_active_ = false;
    }

    bool timeOut();

    void setInterval(float interval) {
        timer_interval_ = interval;
    }

    void setTimer(float timer) {
        timer_ = timer;
    }

    float getTimer() {
        return timer_;
    }

    float getInterval() {
        return timer_interval_;
    }

    float getProgress() {
        return timer_ / timer_interval_;
    }
};


#endif //TIMER_H
